<template>
  <div id="RegisterDialog">
    <el-dialog title="企业注册" width="900px" :visible.sync="show">
      <vj-form @submit="onSubmit" @close="show=false" :slot-idx="cfgList.length-1"
               hide-reset :style-config="{labelWidth:'160px'}"
               :loading="loading" class="vj-form" :cfg-list="cfgList"
               :form-data.sync="formData">
        <el-form-item slot="form-item" label="验证码" required>
          <el-input placeholder="请输入验证码" v-model="validateCode"/>
        </el-form-item>
      </vj-form>
    </el-dialog>
  </div>
</template>
<script lang="ts">
import Vue, {ComponentOptions, VueConstructor} from "vue"
import Component from 'vue-class-component'
import {Mixins} from "vue-property-decorator";
import {FormMixin} from "@/plugins/mixins/form";
import {ActivityFormTB} from "@/config/table";
import {ACTIVITY_FM, ACTIVITY_LINK_FM, CAPITAL_FM, JOB_FM, PIC_FM, PWD_FM, REGISTER_FM, TALENT_FM} from "@/config/form";
import {cloneDeep, formatOptions, hookSubmit, updateCfgOption} from "vijay-util";
import {requestByGet, requestByPost, requestByPut} from "@/utils/request";
import {CommonStore} from "@/store";

@Component
export default class RegisterDialog extends Mixins(FormMixin) implements ComponentOptions<Vue> {
  name = "RegisterDialog"
  show = false;
  editId = null;
  cfgList = REGISTER_FM
  validateCode = null;

  @hookSubmit()
  async onSubmit() {
    await requestByPost(`qqc/qqcBusiness/add`, this.formData);
    this.$message.success("注册成功！");
    this.show = false;
  }

  async initOptions() {
    const {records} = await requestByGet(`qqc/qqcProfession/list`, {pageNo: 1, pageSize: 999});
    this.cfgList = updateCfgOption(this.cfgList, "trade", formatOptions(records, "name", "id"))
  }

  open() {
    this.show = true;
  }

  created() {
    this.initOptions();
  }

}
</script>

<style scoped lang="scss">
@import "~assets/common.scss";

#RegisterDialog {
}
</style>
